home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Apple Script
/
OSAX
/
Finder Scripting Toolkit v1.0
/
fwin coercion osax
/
alis2fwin.c
< prev
next >
Wrap
Text File
|
1993-07-20
|
1KB
|
63 lines
/*
F W I N C O E R C I O N O S A X
Version 1.0
Freeware by Daniel Ranson
This osax performs coercions to the FinderWindow (fwin) record
type used by Finder events.
There are actually three osax. This one converts aliases.
*/
#include <Types.h>
#include <Memory.h>
#include <Aliases.h>
#include <AppleEvents.h>
#include <AERegistry.h>
struct FinderWindow{
long windowType;
DescType aliasType;
long aliasLength;
AliasRecord alias;
};
typedef struct FinderWindow FinderWindow;
pascal OSErr ALIS2FWIN( DescType fromType,
Ptr dataPtr,
Size dataSize,
DescType toType,
long refCon,
AEDesc *result)
{
#pragma unused(fromType, toType, refCon)
FinderWindow **hFwin;
Size sizH;
OSErr err;
/* Allocate the structure */
sizH = sizeof(FinderWindow) + dataSize - sizeof(AliasRecord);
hFwin = (FinderWindow**)NewHandle(sizH);
if (hFwin == 0) return errAECoercionFail;
/* Fill in fields */
(**hFwin).windowType = 0;
(**hFwin).aliasType = typeAlias;
(**hFwin).aliasLength = dataSize;
BlockMove(dataPtr, &((**hFwin).alias), dataSize);
/* Create the descriptor */
MoveHHi((Handle)hFwin);
HLock((Handle)hFwin);
err = AECreateDesc(typeFinderWindow, (Ptr)(*hFwin), sizH, result);
/* Clean up */
DisposeHandle((Handle)hFwin);
return err;
}